import java.util.*;

class Student {
    public String id;

    public Student(String id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id='" + id + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(id, student.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}


public class Test {

    public int singleNumber(int[] nums) {
        //TreeSet<Integer> set = new TreeSet<>();
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            if (!set.contains(nums[i])) {
                set.add(nums[i]);
            } else {
                set.remove(nums[i]);
            }
        }

        for (int i = 0; i < nums.length; i++) {
            if (set.contains(nums[i])) {
                return nums[i];
            }
        }

        return -1;
    }

    public int numJewelsInStones(String jewels, String stones) {
        HashSet<Character> set = new HashSet<>();

        int count = 0;

        for (int i = 0; i < jewels.length(); i++) {
            char ch = jewels.charAt(i);
            set.add(ch);
        }

        for (int i = 0; i < stones.length(); i++) {
            char ch = stones.charAt(i);
            if (set.contains(ch)) {
                count++;
            }
        }

        return count;
    }

    public static void main(String[] args) {

    }

    public static void main6(String[] args) {
        Map<String, Integer> map = new HashMap<>();

        Set<String> set = new HashSet<>();


        HashMap<String, Integer> map2 = new HashMap<>();

    }

    public static void main5(String[] args) {
        Student student = new Student("123456");
        int hashcode1 = student.hashCode();
        System.out.println(hashcode1);


        Student student2 = new Student("123456");
        int hashcode2 = student2.hashCode();
        System.out.println(hashcode2);
        System.out.println("======");

        HashBuck2<Student, Integer> hashBuck2 = new HashBuck2<>();
        hashBuck2.push(student, 123);

        System.out.println(hashBuck2.get(student2));


    }

    public static void main4(String[] args) {
        HashBuck hashBuck = new HashBuck();
        hashBuck.push(4, 888);
        hashBuck.push(1, 888);
        hashBuck.push(2, 888);
        hashBuck.push(3, 888);
        hashBuck.push(5, 888);
        hashBuck.push(6, 888);

        hashBuck.push(14, 1444);

        hashBuck.push(7, 777);


        System.out.println("=====");

        System.out.println(hashBuck.get(14));
    }

    public static void main3(String[] args) {
        //就是不能 存储相同的元素
        Set<String> set = new TreeSet<>();
        set.add("hello");
        set.add("abc");
        set.add("poll");
        set.add("poll");

        //System.out.println(set);

        for (String x : set) {
            System.out.println(x);
        }
    }

    public static void main1(String[] args) {
        /*Map<Student,Integer> map2 = new TreeMap<>();
        map2.put(new Student(),1);*/


        Map<String, Integer> map = new TreeMap<>();
        map.put("abc", 4);
        map.put("hello", 3);
        map.put("poll", 6);
        map.put("poll", 16);

       /* for (String,Integer x : map) {
            System.out.println(x);
        }*/

        Integer val = map.getOrDefault("abc", 99);
        System.out.println(val);

        Set<String> set = map.keySet();
        System.out.println("set: " + set);

        Set<Map.Entry<String, Integer>> set2 = map.entrySet();
        for (Map.Entry<String, Integer> entry : set2) {
            System.out.println("key: " + entry.getKey() + " val: " + entry.getValue());
        }
    }
}